the-odin-journal

CSS

Selectors

Specificity, the Cascade

Sort of like a tie-breaker, when an element has multiple, conflicting declarations targeting it.

The Box Model

graph LR;
    A[Margin] --> B[Border];
    B --> C[Padding];
    C --> D[Content];

Margins

For more details, refer this.

Block and Inline

block and inline are outer display types.

Normal Flow is the way that Block and Inline elements are displayed on a page by default before any changes are made to their layout.

Flexbox

Flex Visual Cheatsheet

Flexbox is an inner display type (flex and inline-flex) to arrange items into rows or columns. These items will flex (i.e. grow or shrink) based on some rules that you can define.

<div class="flex-container">
  <div class="one"></div>
  <div class="two"></div>
  <div class="three"></div>
</div>
.flex-container {
  display: flex;
}
.flex-container div {
  background: peachpuff;
  border: 4px solid brown;
  height: 100px;
  flex: 1;
}

Normalize css

Normalize vs Reset vs Hybrid

Good resources

Undo a reset

use revert keyword

.article :where(h1, h2, h3, h4, h5) {
  all: revert;
}

Within an .article, headings are displayed using the original browser default styles, with appropriate font sizes and weights, thanks to revert

CSS Units

List of all the units

Fonts

Fallback font

Self-hosted fonts

h1 { font-family: my-cool-font, sans-serif; } ```

Style norms

text styles

Pseudo classes and pseudo elements

For details, refer this.

Pseudo-elements:
Allow styling of parts of elements not directly present in HTML, with specificity (0,0,0,1).

Attribute Selectors:
Target elements based on attributes, with specificity (0,0,1,0).